ostree-repo: Make the lock with a long-lasting FD
authorJasper St. Pierre <jstpierre@mecheye.net>
Tue, 22 Nov 2016 00:05:55 +0000 (16:05 -0800)
committerAtomic Bot <atomic-devel@projectatomic.io>
Tue, 22 Nov 2016 02:32:33 +0000 (02:32 +0000)
glnx_make_lock_file requires that the dfd passed in survives the
lifetime of the lock. Since dfd_iter.fd gets cleaned up after the
function returns, this isn't the case. dfd_iter.fd should be equivalent
to tmpdir_dfd, since we iter on ".", and that survives past the
function, so just use that instead.

Closes: #591
Approved by: cgwalters

src/libostree/ostree-repo.c
tests/test-admin-deploy-bootid-gc.sh

index 25893fca3d0e0e72386b121f5daed25b615bdde8..8aa76dacb56c1d811348e796981ecd547ec5868c 100644 (file)
@@ -4869,7 +4869,7 @@ _ostree_repo_allocate_tmpdir (int tmpdir_dfd,
 
       /* We put the lock outside the dir, so we can hold the lock
        * until the directory is fully removed */
-      if (!_ostree_repo_try_lock_tmpdir (dfd_iter.fd, dent->d_name,
+      if (!_ostree_repo_try_lock_tmpdir (tmpdir_dfd, dent->d_name,
                                          file_lock_out, &did_lock,
                                          error))
         goto out;
index ba16f336b9e1ea0d90d6f6901dbf6088ab111000..29360e386948db6ac49d09ea3c6ca4f281e1cc39 100755 (executable)
@@ -51,7 +51,7 @@ fi
 newstagepath=$(ls -d sysroot/ostree/repo/tmp/staging-${NEW_TEST_BOOTID}-*)
 assert_has_dir "${newstagepath}"
 env OSTREE_BOOTID=${NEW_TEST_BOOTID} ${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:testos/buildmaster/x86_64-runtime
-newstagepath=$(ls -d sysroot/ostree/repo/tmp/staging-${NEW_TEST_BOOTID}-*)
+newstagepath=$(echo sysroot/ostree/repo/tmp/staging-${NEW_TEST_BOOTID}-*)
 assert_not_has_dir "${stagepath}"
 assert_not_has_dir "${newstagepath}"